package com.drought.rained.ui.activity.repayment;

import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.drought.rained.R;
import com.drought.rained.base.BaseTitleActivity;
import com.drought.rained.business.RouterMapLJ;
import com.drought.rained.common.ConstantLJ;
import com.drought.rained.utils.StringUtilsLJ;
import com.drought.rained.utils.ToastUtilsLJ;

import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(name = "还款方式",path = RouterMapLJ.REPAY_METHOD_PAGE)
public class PayMethodActivityLJ extends BaseTitleActivity {


    private String mOrderId;
    private String mOrderMoneyNum;
    private boolean isRollover;

    @Override
    protected void initViews() {
        ButterKnife.bind(this);
    }

    @Override
    protected void onUIReady() {
        if (getIntent() == null && StringUtilsLJ.isEmpty(getIntent().getStringExtra(ConstantLJ.ORDER_ID))) {
            ToastUtilsLJ.showShort(PayMethodActivityLJ.this, R.string.illegal_params);
            return;
        }
        mOrderId = getIntent().getStringExtra(ConstantLJ.ORDER_ID);
        mOrderMoneyNum = getIntent().getStringExtra(ConstantLJ.ORDER_MONEY_NUM);
        isRollover = getIntent().getBooleanExtra(ConstantLJ.ORDER_MONEY_IS_ROLLOVER, false);
    }

    @Override
    protected int getContentResId() {
        return R.layout.layout_of_select_pay_method;
    }

    @Override
    public String getPageTitle() {
        return getStringResource(R.string.pay_method_page_title);
    }

    @OnClick({R.id.btn_atm, R.id.btn_otc})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_atm:
                ARouter.getInstance()
                        .build(RouterMapLJ.REPAY_ATM_PAGE)
                        .withString(ConstantLJ.ORDER_ID, mOrderId)
                        .withString(ConstantLJ.ORDER_MONEY_NUM, mOrderMoneyNum)
                        .withBoolean(ConstantLJ.ORDER_MONEY_IS_ROLLOVER, isRollover)
                        .navigation();
                break;
            case R.id.btn_otc:
                ARouter.getInstance()
                        .build(RouterMapLJ.REPAY_OTC_PAGE)
                        .withString(ConstantLJ.ORDER_ID, mOrderId)
                        .withString(ConstantLJ.ORDER_MONEY_NUM, mOrderMoneyNum)
                        .withBoolean(ConstantLJ.ORDER_MONEY_IS_ROLLOVER, isRollover)
                        .navigation();
                break;
        }
    }
}
